package cn.iocoder.yudao.module.signature.dal.mysql.developeraccountversion;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.signature.controller.admin.developeraccountversion.vo.DeveloperAccountVersionPageReqVO;
import cn.iocoder.yudao.module.signature.dal.dataobject.developeraccountversion.DeveloperAccountVersionDO;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * 账号版本信息 Mapper
 *
 * @author base
 */
@Mapper
public interface DeveloperAccountVersionMapper extends BaseMapperX<DeveloperAccountVersionDO> {

    default PageResult<DeveloperAccountVersionDO> selectPage(DeveloperAccountVersionPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<DeveloperAccountVersionDO>()
                .eqIfPresent(DeveloperAccountVersionDO::getAccountId, reqVO.getAccountId())
                .eqIfPresent(DeveloperAccountVersionDO::getVersionTypeCode, reqVO.getVersionTypeCode())
                .eqIfPresent(DeveloperAccountVersionDO::getEnableFlag, reqVO.getEnableFlag())
                .betweenIfPresent(DeveloperAccountVersionDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(DeveloperAccountVersionDO::getId));
    }


    default DeveloperAccountVersionDO selectByAccountIdAndTypeCode(Long accountId, String versionTypeCode) {
        return selectOne(new LambdaQueryWrapperX<DeveloperAccountVersionDO>()
                .eq(DeveloperAccountVersionDO::getAccountId, accountId)
                .eq(DeveloperAccountVersionDO::getVersionTypeCode, versionTypeCode)
                .eq(BaseDO::getDeleted, false));
    }

    default List<DeveloperAccountVersionDO> selectByAccountIds(List<Long> accountIds) {
        return selectList(new LambdaQueryWrapperX<DeveloperAccountVersionDO>()
                .in(DeveloperAccountVersionDO::getAccountId, accountIds)
                .eq(BaseDO::getDeleted, false));
    }

}